package com.lagou.mr.homework1;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.File;
import java.io.IOException;

public class HomeworkDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        final Configuration conf = new Configuration();
        final Job job = Job.getInstance(conf,"HomeworkDriver");

        job.setJarByClass(com.lagou.mr.homework1.HomeworkDriver.class);
        job.setMapperClass(HomeworkMapper.class);
        job.setReducerClass(HomeworkReduce.class);

        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(IntWritable.class);

        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(IntWritable.class);

        job.setNumReduceTasks(1);

        FileInputFormat.setInputPaths(job,new Path("F:\\BigData\\JavaIdea\\homework\\homework1\\input"));
        FileOutputFormat.setOutputPath(job,new Path("F:\\BigData\\JavaIdea\\homework\\homework1\\output"));

        final boolean flag = job.waitForCompletion(true);
        System.exit(flag ? 0:1);
    }
}
